Has anyone set up an error 404 page that automatically returns a list of search entries for the file that is missing? For instance, if I moved a file from one album to another, it would be nice if when they clicked on the link from a search engine it brought them up to my error page and showed the file in the new location, since the file name itself did not change, just the location.
Thanks!
Comments
Also, if you moved an image to another album it is "another" image to Zenphoto as you can have several images with the same file name in different albums as well as subalbums of the same folder name within several albums.
Let's say they were looking for the file "bookmarks/mybookmark.jpg" and it has moved to "bookmarks/English/mybookmark.jpg" I don't need Zenphoto to know it moved, I just need to make it easy to display search results for "mybookmark.jpg" and let Zenphoto search by filename and show the relevant result(s). It doesn't matter where it moved-- it can search for it anyway. I am assuming I could fairly easily retrieve the name that it was looking for because at least the missing album is outputted on the 404 page, so I could probably create a "click here to search for the missing file" link that would link to a search page?
My question is, has anyone already done something like this (so I don't have to reinvent the wheel) or perhaps even incorporated an automatic search results built in to the 404 page? Having the thumbnail automatically appear would prevent people leaving my page after not finding what they wanted right away.
Thanks.
What you want is probably possible as you describe it. Probably also setting up a search automatically using the not found info. As far as I know no one ever tried (at least has not told so).
I suggest to look at the search class documentation on the functions guide.
For instance:
This used to be an album, but when I restructured my directories I needed a way to provide an easy to find navigation for search.
A link to an image and folder that were both moved with search links for both the album and object itself.
Below is the coding I'm using on my 404 page, so I'm sure you can modify it to auto-search if you want, I just never took it that far. It's probably not pretty, or efficient, but it does the job for the most part.
`
<?php
echo gettext("I'm sorry, the link you clicked appears to lead to something that has been moved, is temporarily offline, is missing, or is broken.");
?>
Please click any of the links below (if any) to search for any realtive pages:
<?php
if (isset($album)) {
echo '<br />'.FULLWEBPATH.getSearchURL($album, NULL, NULL, NULL).'';
}
if (isset($image)) {
echo '
'.FULLWEBPATH.getSearchURL($image, NULL, NULL, NULL).'';
}
if (isset($obj)) {
echo '
'.FULLWEBPATH.getSearchURL(substr(basename($obj),0,-4), NULL, NULL, NULL).'';
}
?>
`
(Note that you may want to correct the spelling of "relative" in your code above.)
Nathan
Edit:
Also, let me know if you take it a step further to auto-display search results. I would be interested to see that in action.
If someone knows an easy way to simply redirect to the search page and show results for the required file that would maybe work for me also... otherwise what I have now is sufficient. I suppose I could use javascript on the 404 page to redirect with a little message like "file not found... searching in 3 seconds" etc.
"You can call Zenpage pages on any other page using the object model. So create a Zenpage page and keep it unpublished to call it on the search page."
So perhaps there would be a way to reference the search page too...? No time to look into it now though.
For search options look at the search class and the related template functions.